package br.com.mrh.faces;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.faces.model.SelectItem;

@FacesConverter(value="facesSimpleConvert")
public class FacesSimpleConverter implements Converter {

	public Object getAsObject(FacesContext context, UIComponent component, String value) {      
	     if (value!=null && value.isEmpty())
	         return null;

	     SelectItem selectItem=new SelectItem();
	     selectItem.setLabel(value);
	     return selectItem;     
	}

	public String getAsString(FacesContext context, UIComponent component, Object object) {
	    return ((SelectItem)object).getLabel();
	}

}